# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=memphis
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.2.3
pkgrel=4
arch=('any')
pkgdesc="A map-rendering library for OpenStreetMap (mingw-w64)"
options=(strip staticlibs)
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-expat")
makedepends=("${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "gtk-doc")
options=('strip' 'staticlibs')
license=("GPL 2")
url="https://github.com/jiuka/"
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/jiuka/memphis/archive/${pkgver}.tar.gz"
        001-win.patch)
sha256sums=('10b43b2325ce9937ce33a7afdc247e926cc515ac612b50eb0520e1ac1455e1ab'
            '47dc1f857ff09647429e89fdb4dc8ae451e39afa7e3bf960d8bda63bb193fde5')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/001-win.patch

  libtoolize --copy
  aclocal -I m4
  gtkdocize --copy
  autoreconf -isf
}

build() {
   [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-introspection \
    --enable-vala=no

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}
